---@class UIBillboardReward : UIBase
UIBillboardReward = UIBase.New(PanelResNames.UIBillboardReward)
local t = UIBillboardReward
local language = {[101]="NoticeTips6",[102]="NoticeTips7",[103]="NoticeTips8",
                  [104]="NoticeTips9",[105]="NoticeTips10"}
function t.Init(rewardList)
    t.rewardList = rewardList
    UIBase.Init(t)
end

function t:OnCreate()
    self.bgClose = self:GetChild("bgClose")
    self.buffTip = self:GetChild("buff/buff")
    self.list = self:GetList("list")
    self:SetDynamicList(self.list,self.ItemRender)
    self:RegisterOnClick(self.bgClose,self.ClickClose)
    self:LocalLanguage()
end
function t:LocalLanguage()
    self:GetChild("buff/text").text = getLanguage("NoticeTips3")
    self:GetChild("buff/tips").text = getLanguage("NoticeTips4")
end

function t:OnEnable()
    self:Refresh()
end
function t:OnDisable()
end
function t:OnDestroy()
end
function t:Refresh()
    local buffId = logicMgr.NoticeManager.buffId
    local cfg = G.dataTable["t_ecobuff"][tostring(buffId)]--dataTable.getDataTableByStringId("t_skill",buffId)
    if cfg then
        self.buffTip.text = getLanguage(cfg.f_BuffDesc)
    else
        self.buffTip.text = "找不到skill id:"..logicMgr.NoticeManager.buffId
    end
    local count = #t.rewardList
    self.list.visible = count > 0
    self.list.numItems = count
end
function t:ItemRender(index,go)
    local data = t.rewardList[index]
    local name = go:GetChild("text")
    ---@type GList
    local itemList = go:GetChild("rewardList")
    name.text = getLanguage(language[data.type])
    local rewards = data.data
    local itemCtrl = logicMgr.CtrlManager.GetCtrl(PanelNames.Item)
    itemList:RemoveChildrenToPool()
    for k,v in pairs(rewards) do
        local item = itemList:AddItemFromPool()
        itemCtrl.initData(item,v)
    end
end
function t:ClickClose()
    closeUI(PanelNames.UIBillboardReward)
end
return t